#include "stockpage.h"
#include "ui_stockpage.h"
#include <QHeaderView>

StockPage::StockPage(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::StockPage)
{
    ui->setupUi(this);
    this->setLayout(ui->MainLayout);

    //设置自定义的鼠标指针图案
    QCursor *myCursor= new QCursor(QPixmap(":/Mouse/Image/mouse/mouse.png"),15,10);
    setCursor(*myCursor);

    QStringList headers;
    headers << tr("商品编码") << tr("商品名称") << tr("类别") << tr("单位") << tr("规格") << tr("颜色") << tr("品牌")
            << tr("销售数量") << tr("库存数量")  << tr("成本") << tr("售价")
            << tr("最小库存");

    ui->tableWidgetStock->setColumnCount(12);

//    ui->tableWidgetStock->horizontalHeaderItem->setFont(font);

    ui->tableWidgetStock->setHorizontalHeaderLabels(headers);



//    QTableWidgetItem *columnHeaderItem0 = ui->tableWidgetStock->horizontalHeaderItem(0); //获得水平方向表头的Item对象
//    ui->tableWidgetStock->verticalHeaderItem(0)

    for (int i = 0; i < 12; ++i)
    {
        ui->tableWidgetStock->horizontalHeaderItem(i)->setFont(QFont("Helvetica"));
//        ui->tableWidgetStock->horizontalHeaderItem(i)->setBackgroundColor(QColor(0,60,10));
        ui->tableWidgetStock->horizontalHeaderItem(i)->setTextColor(QColor(200,111,30));
    }

//    ui->tableWidgetStock->setColumnWidth(7,130);
//    ui->tableWidgetStock->setColumnWidth(8,130);

    //设置列宽可拖动
//    ui->tableWidgetStock->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
//    ui->tableWidgetStock->verticalHeader()->setResizeMode(QHeaderView::Interactive);
    //设置table的水平滚动条
    ui->tableWidgetStock->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    ui->tableWidgetStock->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
}

StockPage::~StockPage()
{
    delete ui;
}
